using ASP;
using HoWave.Common;
using HoWave.Data;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Data;
using System.Text;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public class Shop_Manage_shop_style : Member, IRequiresSessionState
{
	public int ShopTemSelID = 0;
	public int ShopID = 0;
	protected DropDownList DropShopSkin;
	protected HiddenField hfSrcName;
	protected Button Button1;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		this.ShopID = base.user.ShopID;
		if (this.ShopID <= 0)
		{
			this.WriteErrMsg("友情提示", Language.GetMemberMsg("Common/NoShop", new string[0]), "../Member/Shop_OpenShop.aspx");
		}
		if (!base.IsPostBack)
		{
			this.BandShopTem();
		}
	}
	protected void BouSaveShopStyle_Click(object sender, EventArgs e)
	{
		ShopGroupBll shopGroupBll = new ShopGroupBll(this.conn);
		string groupPowerByShopID = shopGroupBll.GetGroupPowerByShopID(this.ShopID);
		if (!shopGroupBll.CheckGroupPower(groupPowerByShopID, "changeskin"))
		{
			this.WriteErrMsg("", Language.Get("Shop/Style/NotModifySkin"), "");
		}
		Shop_Shop shop_Shop = new Shop_Shop(this.conn);
		shop_Shop.UpdateShopTem(this.DropShopSkin.SelectedValue, this.ShopID);
		MessageBox.Show(this, Language.Get("Common/Success"));
	}
	protected void BandShopTem()
	{
		SkinBll skinBll = new SkinBll(this.conn);
		DataTable proSkinBySkinType = skinBll.GetProSkinBySkinType("Shop");
		StringBuilder stringBuilder = new StringBuilder();
		for (int i = 0; i < proSkinBySkinType.Rows.Count; i++)
		{
			string text = this.getcssname(proSkinBySkinType.Rows[i]["SkinPath"].ToString());
			if (text != string.Empty)
			{
				ListItem item = new ListItem(proSkinBySkinType.Rows[i]["SkinName"].ToString(), text);
				stringBuilder.Append(proSkinBySkinType.Rows[i]["SkinPreviewImg"].ToString() + ";");
				this.DropShopSkin.Items.Add(item);
			}
		}
		proSkinBySkinType.Dispose();
		this.hfSrcName.Value = stringBuilder.ToString();
		Shop_Shop shop_Shop = new Shop_Shop(this.conn);
		DataTable shopByShopID = shop_Shop.GetShopByShopID(this.ShopID);
		if (shopByShopID != null && shopByShopID.Rows.Count > 0)
		{
			if (shopByShopID.Rows[0]["ShopStatus"].ToString() == "-1")
			{
				this.WriteErrMsg("", Language.Get("Shop/ShopStatus/Close"), "");
			}
		}
		try
		{
			this.DropShopSkin.SelectedValue = shopByShopID.Rows[0]["ShopStyle"].ToString();
		}
		catch
		{
		}
		this.DropShopSkin.Attributes.Add("onchange", "changePreview()");
		int gID = Text.ToInt32(shopByShopID.Rows[0]["ShopGroupID"]);
		ShopGroupBll shopGroupBll = new ShopGroupBll(this.conn);
		string groupPowerById = shopGroupBll.GetGroupPowerById(gID);
		if (!shopGroupBll.CheckGroupPower(groupPowerById, "changeskin"))
		{
			this.DropShopSkin.Enabled = false;
		}
	}
	private string getcssname(string str)
	{
		string result;
		if (str == "" || !str.Contains(".") || !str.Contains("/"))
		{
			result = string.Empty;
		}
		else
		{
			str = str.Remove(str.LastIndexOf('.'));
			str = str.Substring(str.LastIndexOf('/') + 1);
			result = str;
		}
		return result;
	}
}
